package vip.meeet.base;

/**
 * https://mp.weixin.qq.com/s?__biz=MzIyNDU2ODA4OQ==&mid=2247484379&idx=1&sn=cf8619934421bcb3d119c60c733b0dcb&chksm=e80db5addf7a3cbb31e844da61b958b926a9c92d24910be5c6b1545b1bb71110fa381d9b8613&scene=21#wechat_redirect
 */
public class StringStart {


    public static void main(String[] args) {
        referenceArgCall();
    }

    public static void referenceArgCall() {
        StringBuffer a = new StringBuffer("A");
        StringBuffer b = new StringBuffer("B");
        test(a,b);
        System.out.println(a+","+b);
    }

    public static void test(StringBuffer x,StringBuffer y) {
        x.append(y);//AB
        y=x;//y本身是一个值类型的指针，而不是引用本身
    }

    private static void eq1(){
        String st1 = "abc";
        String st2 = "abc";
        System.out.println(st1 == st2);//true,常量池，堆内存，常量池
        System.out.println(st1.equals(st2));//true
    }

    private static void eq2(){
        String st1 = new String("abc");
        String st2 = "abc";
        System.out.println(st1 == st2);//false,st1是在堆内存，st2是常量池对象
        System.out.println(st1.equals(st2));//true
    }

    private static void eq3(){
        String st1 = "a" + "b" + "c";
        String st2 = "abc";
        System.out.println(st1 == st2);//true,常量池
        System.out.println(st1.equals(st2));//true
    }

    private static void eq4(){
        String st1 = "ab";
        String st2 = "abc";
        String st3 = st1 + "c";//对象+之后转化为了一个新对象，而不是常量
        System.out.println(st2 == st3);//false
        System.out.println(st2.equals(st3));//true
    }
}
